package com.taobao.shopcart.feignclient;

import com.taobao.base.model.RestResponse;
import com.taobao.shopcart.model.dto.GoodsDetailsDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class HomeServiceClientFallbackFactory implements FallbackFactory<HomeServiceClient> {



    @Override
    public HomeServiceClient create(Throwable cause) {

        return new HomeServiceClient() {

            @Override
            public RestResponse<String> getGoodsCount(List<Integer> list) {
                log.error("调用home-service服务失败，原因：{}", cause);
                return null;
            }

            @Override
            public RestResponse<GoodsDetailsDto> getGoodsDetail(int goodsId) {
                log.error("调用home-service服务失败，原因：{}", cause);
                return null;
            }
        };
    }
}
